<--- %%NOBANNER%% --> cleartable.sas
 BackForward

/*-------------------<---Start of Description-->---------------------\
| Clear the bookmarked table or the current table;                   |
|---------------------<---End of Description-->----------------------|
|--------------------------------------------------------------------|
|------------<---Start of Files or Arguments Needed-->---------------|
| Argument:                                                          |
|   bmark: a name of table you want to cleared;                      |
|   wordref: word reference; not necessary default is "wordsys";     |
| Note: space will be read as a part of the book mark                |
|    if no bookmark is entered, then clear the current table.        |
|    wordref: you can specify window reference, default if "wordsys";|
| Note: the wordref must be the 2nd paramter;                        |
|-------------<---End of Files or Arguments Needed-->----------------|
|--------------------------------------------------------------------|
|------------------<---Start of Files Created-->---------------------|
| Example: %cleartable('t1');                                        |
| Usage:   %cleartable(bmark,wordref);                               |
\-------------------<---End of Files Created-->---------------------*/
%macro cleartable/parmbuff;
/*--------------------------------------------\
| Author:  Duo Zhou;                          |
| Created: 2-27-2001 8:26pm;                  |
| Purpose: Clear a table;                     |
\--------------------------------------------*/
%local fref wsid rc;
%let bookmark=%qscan(&syspbuff,1,%str(,()''""));
%let fref=;%let wsid=0;
%if %words(&syspbuff, dlm=%quote(,()))>1 %then %do;
   %let fref=%qscan(&syspbuff,-1,%str(,()''""= ));
%end;
%else %do;
   %let fref=wordsys;
%end;
%if (%quote(&bookmark) ne) %then %do;
  %gotobmark("&bookmark");
%end;
%if (&fref ne ) %then %do;
   %let wsid=%sysfunc(fopen(&fref,o,132,e));
%end;
%if &wsid %then %do;
   %let rc=%sysfunc(fclose(&wsid));
   data _null_;
      file &fref lrecl=2000;
      put '[TableSelectTable]';
      put '[EditClear]';
   run;
%end;
%else %do;
   %put ==> Alert! Incorrect window reference "&fref", or window "&fref" isn%str(%')t open.;
%end;
%mend cleartable;